//-----------------------------------------
// 	PicOS Project
//
// 	HEPIA 2014 - Florent Gluck
//
//	Denis Voirol		Pierre Kiss
//	Ruben Magnin		Alina Stanculescu
//	Sebastien Beureux	Julien Cornut
//-----------------------------------------
//
//	syscall.c
//
//	Handle system calls by syscall_nb
//
//-----------------------------------------

#include "syscall.h"
#include "types.h"
#include "const.h"
#include "exec.h"

int syscallHandler (uint syscall_nb, uint arg1, uint arg2, uint arg3)
{
	switch(syscall_nb)
	{
		case SYSCALL_MEMPUTB:
			memPutB(arg2,arg3,arg1);break;
		case SYSCALL_PRINTCHAR:
			printChar((char)arg1); 	break;
		case SYSCALL_READCHAR:
			return readChar();
		case SYSCALL_READSECT:
			return readSect(arg1, arg2);
		case SYSCALL_WRITESECT:
			writeSect(arg1, arg2); 	break;
		case SYSCALL_READFILE:
			readFile(arg1,arg2);  	break;
		case SYSCALL_SETCURSOR:
			setCursorPos(arg1,arg2);break;
		case SYSCALL_GETTICKS:
			return get_ticks();
		case SYSCALL_GETSTAT:
			return(getStat(arg1,arg2));
		case SYSCALL_GETNEXTFILE:
			return(getNextFile(arg1,arg2));
		case SYSCALL_EXEC:
			exec(arg1,arg2); break;
		case SYSCALL_REMOVEFILE:
			removeFile(arg1); break;
		case SYSCALL_GETCURRENTUID:
			return getCurrentUID();
		case SYSCALL_GETLOGIN:
			return getLogin(arg1,arg2);
	}
}
